package com.hulk.rpc.common;

import com.hulk.rpc.annotation.HulkService;

import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

/**
 * @author xuxukang
 * @date 2019-05-03 16:57
 */
@HulkService(rest = "/hulk-service")
public interface HulkConnectService {

  int SERVICE_HEARTBEAT = 0;
  int SERVICE_CLASS_REGISTER = 1;
  int SERVICE_METHOD_REGISTER = 2;
  int SERVICE_REST_REGISTER = 3;
  int SERVICE_CLASS_ID_REGISTER = 4;

  Map<String, Integer> serviceOrderMap = Map.of(//
          "heartbeat", SERVICE_HEARTBEAT, //
          "getClassRegisterList", SERVICE_CLASS_REGISTER, //
          "getMethodRegisterMap", SERVICE_METHOD_REGISTER, //
          "getRestRegisterList", SERVICE_REST_REGISTER, //
          "getClassIdMap", SERVICE_CLASS_ID_REGISTER);

  /**
   * 心跳，true is ok
   */
  @HulkService(version = "1.0.0", rest = "/heartbeat")
  default CompletableFuture<Boolean> heartbeat() {
    return CompletableFuture.completedFuture(Boolean.FALSE);
  }

  /**
   * 获取已注册的RPC类，classString
   */
  @HulkService(version = "1.0.0", rest = "/class/list")
  CompletableFuture<List<String>> getClassRegisterList();

  /**
   * 获取已注册的RPC方法，key:serviceId, value:methodString
   */
  @HulkService(version = "1.0.0", rest = "/method/list")
  CompletableFuture<Map<String, Integer>> getMethodRegisterMap();

  /**
   * 获取已注册的rest服务列表
   */
  @HulkService(version = "1.0.0", rest = "/rest/list")
  CompletableFuture<List<String>> getRestRegisterList();

  /**
   * 获取已注册的 classId
   */
  @HulkService(version = "1.0.0", rest = "/class-id/list")
  CompletableFuture<Map<String, Integer>> getClassIdMap();

}
